﻿using System;
using System.Runtime.InteropServices;

namespace OdsServer.Device.Core
{
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
    internal unsafe struct DEVLIST
    {
        public UInt32           dwDeviceNum;
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 50)]
        public fixed sbyte      szDeviceName        [50];
        public Int16            nNumOfSubDevices;
    }

    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
    internal unsafe struct DEVFEATURES
    {
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
        public fixed sbyte      szDriverVer         [8];
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = ADSCONST.MAX_DRIVER_NAME_LEN)]
        public fixed sbyte      szDriverName        [ADSCONST.MAX_DRIVER_NAME_LEN]; 
        public UInt32           dwBoardID;
        public Int16            usMaxAIDiffChl;
        public Int16            usMaxAISiglChl;
        public Int16            usMaxAOChl;
        public Int16            usMaxDOChl;
        public Int16            usMaxDIChl;
        public Int16            usDIOPort;
        public Int16            usMaxTimerChl;
        public Int16            usMaxAlarmChl;
        public Int16            usNumADBit;
        public Int16            usNumADByte;
        public Int16            usNumDABit;
        public Int16            usNumDAByte;
        public Int16            usNumGain;
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
        public GAINLIST[]       glGainList;
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
        public fixed UInt32     dwPermutation       [4];
    }

    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
    internal unsafe struct GAINLIST
    {
        public UInt16           usGainCde;
        public Single           fMaxGainVal;
        public Single           fMinGainVal;
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
        public fixed sbyte      szGainStr[16];
    }

    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
    internal struct PT_AIConfig
    {
        public UInt16 DasChan;
        public UInt16 DasGain;
    }

    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
    internal struct PT_AIBinaryIn
    {
        public UInt16 chan;
        public UInt16 TrigMode;
        public IntPtr reading; // USHORT*
    }
}
